# $Id: django_bootstrap.py 32 2009-04-18 14:37:16Z fred1982 $
# Author: zhuzhu@perlchina.org
# a blog system on app engine
#

# Standard Python imports.
import os
import sys
#import logging
import __builtin__
import django.http

# Google App Hosting imports
from google.appengine.ext.webapp import util

# Force Django to reload its settings.
from django.conf import settings
settings._target = None

import pickle
sys.modules['cPickle'] = pickle

# Enable info logging
#logging.getLogger().setLevel(logging.INFO)

# Force sys.path to our own directory first.
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))

# Must set this env var *before* import any part of Django.
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

try:
    from django import v0_96 as django
except ImportError:
    pass

# Import the part of Django that we use here.
import django.core.handlers.wsgi

def main():
# Create a Django appliaction for WSGI.
    application = django.core.handlers.wsgi.WSGIHandler()

# Run the WSGI CGI handler with that application.
    util.run_wsgi_app(application)

if __name__ == '__main__':
    main()
